package cn.tarena.ht.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.tarena.ht.mapper.ModuleMapper;
import cn.tarena.ht.pojo.Module;
@Service
public class ModuleServiceImpl implements ModuleService {
	@Autowired
	private ModuleMapper moduleMapper;
	
	public List<Module> findAll() {
		return moduleMapper.findAll();
	}

	public void updateState(String[] moduleIds, int state) {
		for (String moduleId : moduleIds) {
			moduleMapper.updateState(moduleId, state);
		}
	}

	public void deleteModule(String[] moduleIds) {
		for (String moduleId : moduleIds) {
			moduleMapper.deleteRoleModule(moduleId);
			moduleMapper.deleteModule(moduleId);
		}
	}

	public void saveModule(Module module) {
		moduleMapper.saveModule(module);
	}

	public void updateModule(Module module) {
		moduleMapper.updateModule(module);
	}

	public Module findModuleById(String moduleId) {
		return moduleMapper.findModuleById(moduleId);
	}
	
}
